<template>
	<view class="statisticsBox">
		<view class="navBox">
			<u-navbar title="体验统计" :titleStyle="{fontWeight:'900'}" bgColor="#ffffff">
				<view class="u-nav-slot" slot="left"></view>
			</u-navbar>
		</view>
		<view class="topBox" :style="'top:'+(20+(customBarHeight*2))+'rpx;'">
			<view class="searchBox">
				<u-icon name="search" color="#49a1fd" size="40"></u-icon>
				<u-input border="none" placeholder="搜索体验名称" v-model="keyWords" @confirm="getStatisticsList"
					:clearable="true" @clear="clearSearch"></u-input>
			</view>
		</view>
		<scroll-view scroll-y="true" class="scroll-Y statisticsListBox"
			:style="'height:'+(pageHeight-(130+customBarHeight))+'px;top:'+(130+(customBarHeight*2))+'rpx;'">
			<view class="statisticsList " v-if="statisticsList.length>0">
				<view class="statisticsItem" v-for="(item,index) in statisticsList" :key="index"
					@click="navigatorPage(item)">
					<view class="itemLeft">
						<view class="nameBox">
							<view class="lebel">活动名称:</view>
							<view class="name">{{item.name}}</view>
						</view>
						<view class="timeBox">
							<view class="lebel">体验时间:</view>
							<view class="value">{{item.start_time}} ~ {{item.end_time}}</view>
						</view>
						<view class="numBox">
							<view class="lebel">项目数量:</view>
							<view class="value">{{item.count}}</view>
						</view>
					</view>
					<view class="itemRight">
						<image src="../../static/images/arrow-right.png" class="image"></image>
					</view>
				</view>
			</view>
			<view class="noData" v-else>
				<image src="../../static/images/nodata.png" class="image"></image>
				<view class="text">暂时还没有统计数据哦～</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	const app = getApp();
	import {
		getStatisticsList
	} from "@/api/api.js"
	export default {
		data() {
			return {
				keyWords: null,
				customBarHeight: Number(44 + app.globalData.statusBar),
				pageHeight: 0,
				statisticsList: []
			}
		},
		methods: {
			onLoadMethod() {
				this.keyWords = null
				let that = this
				uni.getSystemInfo({
					success(res) {
						that.pageHeight = Number(res.windowHeight)
					}
				})
				this.getStatisticsList()
			},
			onHideMethod() {
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 0
				});
			},
			clearSearch() {
				this.keyWords = null
				this.getStatisticsList()
			},
			getStatisticsList() {
				getStatisticsList({
					name: this.keyWords,
				}).then(res => {
					this.statisticsList = res.data
				})
			},
			navigatorPage(item) {
				uni.navigateTo({
					url: "/pages/school/school?experience_id=" + item.id + "&experience_name=" + item.name
				})
			},

		}
	}
</script>

<style lang="scss" scoped>
	.fillBox {
		width: 100%;
		height: 120rpx;
		background: #f8f8f8;
	}

	.statisticsBox {
		min-height: 100vh;
		background-color: #f8f8f8;
	}

	.navBox {
		position: relative;
		z-index: 1000;
	}

	.topBox {
		width: 100%;
		position: fixed;
		top: 160rpx;
		z-index: 100;

		.searchBox {
			position: relative;
			display: flex;
			margin: 0rpx 34rpx;
			align-items: center;
			padding: 0 20rpx;
			height: 88rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 12rpx 116rpx 0rpx rgba(196, 203, 214, 0.1);
			border-radius: 24rpx;
		}

		/deep/ .searchBox .u-input {
			height: 100%;
			padding: 0 20rpx !important;
		}
	}


	.statisticsListBox {
		position: relative;

		.statisticsList {
			position: relative;
			z-index: 200;
			padding-bottom: 120rpx;

			.statisticsItem {
				display: flex;
				align-items: center;
				padding: 16rpx 28rpx;
				margin: 0rpx 34rpx 20rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 0rpx 4rpx 0rpx rgba(0, 0, 0, 0.04);
				border-radius: 20rpx;

				.itemLeft {
					flex: 1;

					.nameBox,
					.timeBox,
					.numBox {
						font-size: 28rpx;
						color: #737373;
						display: flex;
						align-items: center;
					}

					.timeBox {
						margin: 12rpx 0 14rpx;
					}

					.lebel {
						color: #000000;
						margin-right: 20rpx;
						width: 120rpx;
					}

					.name {
						color: #000000;
						font-weight: bold;
						flex: 1;
					}

					.value {
						flex: 1;
						font-size: 24rpx;
					}
				}

				.itemRight {
					margin-left: 20rpx;

					.image {
						width: 16rpx;
						height: 24rpx;
					}
				}
			}
		}
	}
</style>